var HOST = $('body').attr('data-host');
$(function () {

    $('input').keydown(function () {
        $('#insert_info').removeAttr('disabled');
    });

    $('#insert_info').click(function () {

        var phone = $("input[name='phone']").val();
        var company_name = $("input[name='company_name']").val();
        var address = $("input[name='address']").val();
        var company_info = $("textarea[name='company_info']").val();

        if(!phone || !address || !company_info || !company_name){
            alert('信息不能不能为空哦');return false;
        }

        $("#insert_info").attr('disabled','disabled');
        $.ajax({
            type: "POST",
            url: HOST + "/cloud.info/insert_info",
            data: $('.form-horizontal').serialize(),// 你的formid
            async: false,
            success: function (data) {
                if (data.info == 1) {
                    $("#insert_info").removeAttr('disabled');
                    toastr.success('保存成功');

                } else {
                    toastr.erreo('发生异常');

                }

            }
        });

    });
});